<div class="section">
	<div class="block">
		<?php
		$form = $this->beginWidget('PsActiveForm', array(
			'id' => 'ps-update-hierarchy-form',
		));
		?>
		<table class="form-table">
			<tr>
				<th scope="row" width="150"><?php echo $form->labelEx($hierarchy, 'name', array('label' => 'Career Path Name')); ?></th>
				<td>
					<?php echo $form->textField($hierarchy, 'name', array('size' => 45)); ?>
					<?php echo $form->error($hierarchy, 'name'); ?>
				</td>
			</tr>
			<tr>
				<th scope="row" width="150"><?php echo $form->labelEx($hierarchy, 'from_date', array('label' => 'Effective From')); ?></th>
				<td>
					<?php
					$form->widget('PsJuiDatePicker', array(
						'model' => $hierarchy,
						'attribute' => 'from_date',
						'options' => array(
							'showButtonPanel' => false,
							'changeYear' => true,
							'changeMonth' => true,
							'yearRange' => 'c-20:c+5',
							'dateFormat' => 'dd-mm-yy',
						),
					));
					?>
					<?php echo $form->error($hierarchy, 'from_date'); ?>
				</td>
			</tr>
		</table>
		<br/>
		<?php
		$this->widget('PsGridView', array(
			'id' => 'admin-designations-grid',
			'dataProvider' => $this->getDesignationDataProvider($hierarchy->id),
			'template' => '{items}{pager}',
			'pagerCssClass' => 'pager float-right',
			'pagesizeCssClass' => 'pager-pagesize float-right',
			'htmlOptions' => array(
				'class' => 'grid-view grey'
			),
			'columns' => array(
				'sortColumn' => array(
					'class' => 'common.widgets.grid.PsSortableColumn',
					'header' => '',
					'name' => 'id',
					'htmlOptions' => array(
						'width' => 16,
					)
				),
				'pos' => array(
					'header' => 'Rank',
					'name' => 'pos',
					'value' => '$data->pos',
					'htmlOptions' => array(
						'width' => 50,
					)
				),
				'name' => array(
					'header' => 'Title',
					'name' => 'name',
					'type' => 'raw',
					'value' => 'CHtml::link($data->name, array("designations/update", "id" => $data->id), array("class" => "blue link"))'
				),
				'abbreviation' => array(
					'header' => 'Abbrevation',
					'name' => 'abbreviation',
					'value' => '$data->abbreviation ? $data->abbreviation : "-"',
					'htmlOptions' => array(
						'width' => '100'
					)
				),
				'num_users' => array(
					'header' => 'No. of Users',
					'value' => '$data->getUsersCount()'
				),
				'delete' => array(
					'class' => 'CButtonColumn',
					'template' => '{delete}',
					'deleteButtonUrl' => 'array("designations/delete", "id" => $data->id)',
					'afterDelete' => 'modules.admin.hierarchy.update.onDeleteDesignationSuccess',
				)
			)
		));
		?>
		<div class="row">
			<a title="Add Designation" class="blue link" href="<?php echo $this->createUrl('designations/create/' . $hierarchy->id); ?>">
				<img src="/images/icons/fugue/plus-button.png" /> Add Designation
			</a>
		</div>
		<br/>
		<div class="row">
			<input class="green" type="submit" value="Save Changes" id="btnSaveChanges" />
			<a href="<?php echo $this->createUrl('hierarchy/index', array()); ?>" class="link-button no-margin">Cancel</a>
		</div>

		<?php $this->endWidget(); ?>
	</div>
</div>